package com.nt.train.controller;

import com.nt.train.configuration.properties.JdbcConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author hlf
 * @version 1.0
 * @date 2022/7/31 21:14
 */
@RestController
public class PropertieController {

    @Autowired
    private Environment environment;

    @Autowired
    JdbcConfig jdbcConfig;

    //方式1
    @GetMapping("/test/properties")
    public Map<String,Object> readInfo(){
        Map<String,Object> map = new HashMap<>();
        map.put("driver",jdbcConfig.getDriver());
        map.put("url",jdbcConfig.getUrl());
        map.put("username",jdbcConfig.getUsername());
        map.put("password",jdbcConfig.getPassword());
        return  map;
    }
}
